package yesCaptcha

import (
	"context"
	"gitee.com/kaylee595/gkaylee/kerr"
)

type RespGetBalance struct {
	BaseResponse
	Balance       float64 `json:"balance"`       // 帐户余额（点数）1元1000点, 验证码价格参考: https://yescaptcha.atlassian.net/wiki/spaces/YESCAPTCHA/pages/164286
	SoftBalance   float64 `json:"softBalance"`   // 开发者分成余额
	InviteBalance float64 `json:"inviteBalance"` // 邀请分成
	InviteBy      int     `json:"inviteBy"`      // 当前帐户被谁邀请
}

func (c *Client) GetBalance(ctx context.Context) (*RespGetBalance, error) {
	const url = "/getBalance"
	ret := &RespGetBalance{}
	resp := c.httpClient.Post(url).SetBodyJsonMarshal(&BaseRequest{ClientKey: c.clientKey}).SetSuccessResult(ret).Do(ctx)
	if resp.Err != nil {
		return nil, kerr.WrapTraceStack(resp.Err)
	}
	if ret.IsError() {
		return nil, kerr.WrapTraceStack(ret)
	}
	return ret, nil
}
